<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function* fn() {

            yield setTimeout(() => {
                console.log(1)
            }, 3000);
            
            yield setTimeout(() => {
                console.log(2)
            }, 2000);
            yield setTimeout(() => {
                console.log(3)
            }, 1000);
        }
        let res = fn();
        res.next();
        res.next();
        res.next();
    </script>
</body>

</html>